# See: https://hub.docker.com/_/php/
FROM php:7.1.5-fpm
MAINTAINER oldzhuang <zql_0539@163.com>

# install php extensions
RUN apt-get update && apt-get install -y \
        g++ \
        libfreetype6-dev \
        libjpeg62-turbo-dev \
        libmcrypt-dev \
        libpng12-dev \
        libssl-dev \
    && docker-php-ext-install -j$(nproc) iconv mcrypt \
    && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
    && docker-php-ext-install -j$(nproc) gd mysqli pdo_mysql zip opcache

# install ext: redis xdebug mongodb yaf
RUN pecl install redis-3.1.2 \
    && pecl install xdebug-2.5.0 \
    && pecl install mongodb-1.2.9 \
    && pecl install yaf-3.0.4 \
    && docker-php-ext-enable redis xdebug mongodb yaf

# install ext: memcached
RUN apt-get update && apt-get install -y libmemcached-dev zlib1g-dev \
        && pecl install memcached-3.0.3 \
        && docker-php-ext-enable memcached

#ENV PQ_VERSION 2.1.0
#RUN curl -L -o /tmp/pq.tar.gz https://pecl.php.net/get/pq-${PQ_VERSION}.tgz \
#    && tar xzf /tmp/pq.tar.gz -C /tmp \
#    && mkdir -p /usr/src/php/ext \
#    && mv /tmp/pq-${PQ_VERSION} /usr/src/php/ext/pq \
#    && echo 'pq' >> /usr/src/php-available-exts \
#    && docker-php-ext-install pq \
#    && rm -rf /usr/src/php/ext/pq
#
## yaf ext
#ENV PGSQL_VERSION 1.0.2
#RUN curl -L -o /tmp/pdo_pgsql.tar.gz https://pecl.php.net/get/PGSQL_VERSION-${PG_VERSION}.tgz \
#    && tar xzf /tmp/pdo_pgsql.tar.gz -C /tmp \
#    && mkdir -p /usr/src/php/ext \
#    && mv /tmp/PDO_PGSQL-${PGSQL_VERSION} /usr/src/php/ext/pdo_pgsql \
#    && echo 'pdo_pgsql' >> /usr/src/php-available-exts \
#    && docker-php-ext-install pdo_pgsql \
#    && rm -rf /usr/src/php/ext/pdo_pgsql


## yaf ext
#ENV YAF_VERSION 3.0.4
#RUN curl -L -o /tmp/yaf.tar.gz https://github.com/laruence/yaf/archive/yaf-${YAF_VERSION}.tar.gz \
#    && tar xzf /tmp/yaf.tar.gz -C /tmp \
#    && mkdir -p /usr/src/php/ext \
#    && mv /tmp/yaf-yaf-$YAF_VERSION /usr/src/php/ext/yaf \
#    && echo 'yaf' >> /usr/src/php-available-exts \
#    && docker-php-ext-install yaf \
#    && rm -rf /usr/src/php/ext/yaf
#
## redis ext
#ENV PHPREDIS_VERSION 3.0.0
#RUN curl -L -o /tmp/redis.tar.gz https://github.com/phpredis/phpredis/archive/${PHPREDIS_VERSION}.tar.gz \
#    && tar xzf /tmp/redis.tar.gz -C /tmp \
#    && mkdir -p /usr/src/php/ext \
#    && mv /tmp/phpredis-$PHPREDIS_VERSION /usr/src/php/ext/redis \
#    && echo 'redis' >> /usr/src/php-available-exts \
#    && docker-php-ext-install redis \
#    && rm -rf /usr/src/php/ext/redis
